package com.jintian.smart.kernel.flowable.flowable.engine.el;

import java.lang.reflect.Array;

import org.flowable.common.engine.impl.de.odysseus.el.misc.TypeConverterImpl;

public class TypeConverterExtend extends TypeConverterImpl {
    private static final long serialVersionUID = 1L;

    protected Object coerceToType(Object value, Class<?> type) {
        if (type.isArray() && value.getClass().isArray()) {
            int len = Array.getLength(value);
            Class<?> targetClass = type.getComponentType();
            Object[] ret = (Object[]) Array.newInstance(targetClass, len);
            for (int i = 0; i < len; i++) {
                ret[i] = this.coerceToType(Array.get(value, i), targetClass);
            }
            return ret;
        }
        return super.coerceToType(value, type);
    }
}
